package ast.stmt;

import icg.Quadruple;
import ast.Node;
import ast.type.Type;

public class CtrlFlowStmt extends Statement {
	private Boolean continua;

	public CtrlFlowStmt(Boolean continua) {
		this.continua = continua;
	}

	@Override
	public String toString() {
		if (continua)
			return "<Continue />";
		return "<Break />";
	}

	@Override
	public void typeCheck(Type type) {

	}

	@Override
	public Boolean hasCtrlFlow() {
		return true;
	}

	@Override
	public void genCode() {
		if (continua) {
			Node.icg.gen(Quadruple.jump(WhileStmt.continueL));
			WhileStmt.continueL = null;
		} else {
			Node.icg.gen(Quadruple.jump(WhileStmt.breakL));
			WhileStmt.continueL = null;
		}
	}
}
